<div class="drives form">
<?php echo $this->Form->create('Drive'); ?>
	<fieldset>
		<legend><?php echo __('Add Drive'); ?></legend>
	<?php
		echo $this->Form->input('description');
		echo $this->Form->input('date', array('type' => 'text', 'id' => 'date'));
		echo $this->Form->input('value');
		echo '<div class="input text">';
		echo '<label for="type">Tipo de Movimentação</labe><br /><br />';
		echo $this->Form->select('type',array("enter" => "Movimentação de entrada", "exit" => "Movimentação de saída"), array('id' => 'type','style' => 'width: 100%'));
		echo '</div>';
		echo '<div class="input text">';
		echo '<label for="type">Natureza da Movimentação</labe><br /><br />';
		echo $this->Form->select('nature',array("0" => "Selecione um tipo de Movimentação"), array('id' => 'nature', 'style' => 'width: 100%'));
		echo '</div>';
		echo '<div id="form">';
		echo '</div>';
		
		echo $this->Form->input('contract_id');
		
	?>
	</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
	
</div>
<div class="actions">
	<h3><?php echo __('Actions'); ?></h3>
	<ul>
		<li><?php echo $this->Html->link(__('List Drives'), array('action' => 'index')); ?></li>
		<li><?php echo $this->Html->link(__('List Users'), array('controller' => 'users', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New User'), array('controller' => 'users', 'action' => 'add')); ?> </li>
		<li><?php echo $this->Html->link(__('List Contracts'), array('controller' => 'contracts', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New Contract'), array('controller' => 'contracts', 'action' => 'add')); ?> </li>
	</ul>
</div>

<?php 
	  $this->Js->get('#type');
	  echo $this->Js->event('change',
	 		'var type = $("#type").val();'.
	 		'if(type == "enter"){'.
	 		'$("#nature").html("<option value=\"0\">Selecione</option><option value=\"Pagamento de aluguel\">Pagamento de aluguel</option><option value=\"Outros\">Outros</option>")} else {'.
	 		'$("#nature").html("<option value=\"0\">Selecione</option><option value=\"Repasse de aluguel\">Repasse de aluguel</option><option value=\"Pagamento de vale\">Pagamento de vale</option><option value=\"Pagamento de salário\">Pagamento de salário</option><option value=\"Outros\">Outros</option>")}'
		);

	 $this->Js->get('#nature');
	 echo $this->Js->event('change',
	 		$this->Js->request(
	 			array('action' => 'getForm'),
	 			array('method' => 'post',
	            'type' => 'json',
	            'async' => true,
	            'update' => '#form',
	            'dataExpression' => true,
	            'data' => $this->Js->serializeForm(array('isForm' => true, 'inline' => true)))
	 			)	 			
	 	);
	 echo $this->Js->writeBuffer();
?>
